import Vue from 'vue'


import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'

import router from "./router"

import api from "./utils/api"

//对路由进行拦截

router.beforeEach((to,from,next)=>{
  // console.log("-------------即将跳转的路径------------");
  // console.log(to);
  if(to.path!='/login'){
    //debugger;
    var token=localStorage.getItem("token");
    if(token==undefined||token==''){
      next({path:'/login'});
    }
    if(to.matched.length<1){
      next({path:'/home'});
    }
  }
  next();
});

Vue.use(ElementUI);

Vue.config.productionTip = false

Vue.prototype.api= api


new Vue({
  el:"#app",
  router,
  render: h => h(App)
});
